package com.kgc.info;

public class Commoditys {
    private int serial;
    private String name;
    private String category;
    private int price;
    private int quantity;

    public int getSerial(){
        return this.serial;
    }
    public void setSerial(int serial){
        this.serial=serial;
    }
    public String getName(){
        return this.name;
    }
    public void setName(String name){
        this.name=name;
    }
    public String getCategory(){
        return this.category;
    }
    public void setCategory(String category){
        this.category=category;
    }
    public int getPrice(){
        return this.price;
    }
    public void setPrice(int price){
        if (price>0){
            this.price=price;
        }
        else {
            this.price=5;
            throw new RuntimeException("数量要大于0");
        }
    }
    public int getQuantity(){
        return this.quantity;
    }
    public void setQuantity(int quantity){
        if (quantity>0){this.quantity=quantity;}
        else {
            this.quantity=5;
            throw new RuntimeException("价格要大于0");
        }
    }
    public void show(){
        System.out.println("姓名"+this.name+"编号"+this.serial+"类别"+this.category+"数量"+this.price+"价格"+this.quantity);
    }
}
